<template>
  <div class="detail_container">
    <div class="head_title" v-if="!detailForm.id">创建医疗机构信息</div>
    <div class="head_title" v-else-if="detailForm.id && isEdit">编辑医疗机构信息</div>
    <div class="head_title" v-else-if="detailForm.id && !isEdit">查看医疗机构信息</div>
    <el-divider></el-divider>
    <div class="px-20">
      <el-form :model="params" :disabled="detailForm.id && !isEdit" ref="expertForm" class="divForm" label-width="75px" :rules="rules" label-position="left" size="small">


        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="统一信用代码" prop="creditCode">
              <el-input v-model="params.creditCode" placeholder="请输入统一信用代码" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="记分" prop="scoring">
              <el-input v-model="params.scoring" placeholder="请输入记分" />
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="医疗等级" prop="medicalLevel">
              <el-input v-model="params.medicalLevel" placeholder="请输入医疗等级" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="备案状态" prop="recordStatus">
              <el-radio-group v-model="params.recordStatus">
                <el-radio label="1">请选择字典生成</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="备案开始时间" prop="recordStart">
              <el-input v-model="params.recordStart" placeholder="请输入备案开始时间" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="备案结束时间" prop="recordEnd">
              <el-input v-model="params.recordEnd" placeholder="请输入备案结束时间" />
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="备案证件" prop="recordCertificates">
              <el-input v-model="params.recordCertificates" placeholder="请输入备案证件" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="医生人数" prop="physicianNum">
              <el-input v-model="params.physicianNum" placeholder="请输入医生人数" />
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="护士人数" prop="nurseNum">
              <el-input v-model="params.nurseNum" placeholder="请输入护士人数" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="创建人id" prop="createId">
              <el-input v-model="params.createId" placeholder="请输入创建人id" />
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="更新人id" prop="updateId">
              <el-input v-model="params.updateId" placeholder="请输入更新人id" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="删除标志" prop="delFlag">
              <el-input v-model="params.delFlag" placeholder="请输入删除标志" />
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>
    </div>
    <div class="flex p-20">
      <el-button @click="sureForm('expertForm')" type="primary" v-if="!detailForm.id || isEdit">确认提交</el-button>
      <el-button @click="isEdit = true" type="primary" v-if="detailForm.id && !isEdit">编辑</el-button>
      <el-button @click="show = false">返回</el-button>
    </div>
  </div>
</template>

<script>
  export default{
    data () {
      return {
        params:{
            id: null,
            creditCode: null,
            scoring: null,
            medicalLevel: null,
            recordStatus: null,
            recordStart: null,
            recordEnd: null,
            recordCertificates: null,
            physicianNum: null,
            nurseNum: null,
            createId: null,
            createBy: null,
            createTime: null,
            updateId: null,
            updateBy: null,
            updateTime: null,
            delFlag: null,
        },
        rules: {
        }
      }
    },
    props: {
      editVisible: {
        type: Boolean,
        default: () => {
          return false
        }
      },
      detailForm: {
        type: Object,
        default: () => {
          return {}
        }
      },
      isEdit:{
        type:Boolean,
        default:()=>{
          return false
        }
      },
    },
    watch:{

    },
    computed: {
      show: {
        get () {
          return this.editVisible
        },
        set (val) {
          this.$emit('update:editVisible', val)
        }
      },
    },
    created () {
      if(this.detailForm.id){
        this.params = {...this.detailForm}
      }
    },
    methods: {
      // 确认
      sureForm(formName) {
        this.$refs [formName].validate((valid) => {
          if (valid) {
            if(this.detailForm.id){
              this.$emit('submitForm', this.params,this.detailForm.id)
            }else{
              this.$emit('submitForm', this.params)
            }
          } else {
            console.log('error submit!!');
            return false;
          }
        });

      },
    }

  }
</script>

<style scoped="scoped" lang="scss">
  .titile_txt{
    font-family: Source Han Sans SC, Source Han Sans SC;
    font-weight: bold;
    font-size: 16px;
    color: #333333;
    line-height: 19px;
    margin-bottom: 15px;
  }
</style>
